package com.wyj.wuliwuli.controller;

import com.wyj.wuliwuli.common.AjaxRequest;
import com.wyj.wuliwuli.common.AjaxResult;
import com.wyj.wuliwuli.common.PageParam;
import com.wyj.wuliwuli.entity.WuliUser;
import com.wyj.wuliwuli.service.WuliUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Author wyj
 * @version 1.0
 * @date 2022/2/14 18:11
 * @description
 */
@Api(tags = "用户")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/wuli-user")
public class WuliUserController {

    private final WuliUserService wuliUserService;

    @ApiOperation(value = "根据id查询")
    @GetMapping("/{id}")
    public AjaxResult getById(@PathVariable Long id) {
        return wuliUserService.getById(id);
    }


    @ApiOperation(value = "注册新用户")
    @PostMapping("/register")
    public AjaxResult register(@RequestBody AjaxRequest<WuliUser> ajaxRequest) {
        return wuliUserService.register(ajaxRequest);
    }


    @ApiOperation(value = "更新")
    @PostMapping("/update")
    public AjaxResult update(@RequestBody AjaxRequest<WuliUser> ajaxRequest) {
        return wuliUserService.update(ajaxRequest);
    }


    @ApiOperation(value = "全量查询")
    @GetMapping("/list")
    public AjaxResult list() {
        return wuliUserService.list();
    }

    @ApiOperation(value = "分页查询")
    @PostMapping("/page")
    public AjaxResult page(@RequestBody AjaxRequest<PageParam> ajaxRequest) {
        return wuliUserService.page(ajaxRequest);
    }

    @ApiOperation(value = "修改密码")
    @PostMapping("/password")
    public AjaxResult password(@RequestBody AjaxRequest<WuliUser> ajaxRequest) {
        return wuliUserService.password(ajaxRequest);
    }

    @ApiOperation(value = "根据id删除")
    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody AjaxRequest<Object> ajaxRequest) {
        return wuliUserService.delete(ajaxRequest);
    }


}
